package com.spring.alibaba.producer.controller;

import com.spring.alibaba.producer.model.Goods;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/factory")
@RefreshScope
public class ProduceController {

    @Value("${goodsName:default}")
    private String goodsName;
    @Value("${goodsPrice:0}")
    private Integer goodsPrice;

    @GetMapping("/produce")
    public Goods produce() {
        Goods goods = new Goods();
        goods.setName(goodsName);
        goods.setPrice(goodsPrice);
        return goods;
    }
}
